//验证二叉搜索树（空树是二叉树搜索树）
class Solution {
public:
    bool flag = true;
    int judge = 0;
    bool recursion(TreeNode* root)
    {
        if(root == nullptr){
            return true;
        }
        if(recursion(root->left))
        {
            if(flag)
            {
                judge = root->val;
                flag = false;
            }
            else
            {
                if(judge >= root->val)
                {
                    return false;
                }
                else{
                    judge = root->val;
                }
            }
        }
        else
        {
            return false; 
        }
        return recursion(root->right);
    }
    bool isValidBST(TreeNode* root) {
        return recursion(root);
    }
};